Added trace buffer virtual irq to implement non-polling trace record access.
authorkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>
Sat, 8 Apr 2006 08:05:53 +0000 (09:05 +0100)
committerkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>
Sat, 8 Apr 2006 08:05:53 +0000 (09:05 +0100)
Signed-off-by: Rob Gardner <rob.gardner@hp.com>
xen/common/trace.c
xen/include/public/xen.h
xen/include/xen/softirq.h

index b0594aa0a877608103d19cc4883dfe68841506d9..dbd0f7e7a083f35a9f240b9474b4c12d19ebbda3 100644 (file)
@@ -27,6 +27,8 @@
 #include <xen/smp.h>
 #include <xen/trace.h>
 #include <xen/errno.h>
+#include <xen/event.h>
+#include <xen/softirq.h>
 #include <xen/init.h>
 #include <asm/atomic.h>
 #include <public/dom0_ops.h>
@@ -40,6 +42,11 @@ static struct t_buf *t_bufs[NR_CPUS];
 static struct t_rec *t_recs[NR_CPUS];
 static int nr_recs;
 
+/* High water mark for trace buffers; */
+/* Send virtual interrupt when buffer level reaches this point */
+static int t_buf_highwater;
+
+
 /* a flag recording whether initialization has been done */
 /* or more properly, if the tbuf subsystem is enabled right now */
 int tb_init_done;
@@ -50,6 +57,12 @@ static unsigned long tb_cpu_mask = (~0UL);
 /* which tracing events are enabled */
 static u32 tb_event_mask = TRC_ALL;
 
+static void trace_notify_guest(void)
+{
+    send_guest_global_virq(dom0, VIRQ_TBUF);
+}
+
+
 /**
  * alloc_trace_bufs - performs initialization of the per-cpu trace buffers.
  *
@@ -93,6 +106,9 @@ static int alloc_trace_bufs(void)
         t_recs[i] = (struct t_rec *)(buf + 1);
     }
 
+    t_buf_highwater = nr_recs >> 1; /* 50% high water */
+    open_softirq(TRACE_SOFTIRQ, trace_notify_guest);
+
     return 0;
 }
 
@@ -272,6 +288,13 @@ void trace(u32 event, unsigned long d1, unsigned long d2,
     buf->prod++;
 
     local_irq_restore(flags);
+
+    /*
+     * Notify trace buffer consumer that we've reached the high water mark.
+     *
+     */
+    if ( (buf->prod - buf->cons) == t_buf_highwater )
+        raise_softirq(TRACE_SOFTIRQ);
 }
 
 /*
index e18fbf96690c27b506f6f0278142cd5bbf1f0e39..8b2faffc6f686b8bfddfe2d7757bf30fa07485f2 100644 (file)
@@ -77,6 +77,7 @@
 #define VIRQ_DEBUG      1  /* V. Request guest to dump debug info.           */
 #define VIRQ_CONSOLE    2  /* G. (DOM0) Bytes received on emergency console. */
 #define VIRQ_DOM_EXC    3  /* G. (DOM0) Exceptional event for some domain.   */
+#define VIRQ_TBUF       4  /* G. (DOM0) Trace buffer has records available.  */
 #define VIRQ_DEBUGGER   6  /* G. (DOM0) A domain has paused for debugging.   */
 #define VIRQ_XENOPROF   7  /* V. XenOprofile interrupt: new sample available */
 #define NR_VIRQS        8
index 9293b3168e3f5e569e7b9c9128f480ce51b01f0d..f4d484f43b275339b682d01b6f6f1c38623e4623 100644 (file)
@@ -9,7 +9,8 @@
 #define NMI_SOFTIRQ                       4
 #define PAGE_SCRUB_SOFTIRQ                5
 #define DOMAIN_SHUTDOWN_FINALISE_SOFTIRQ  6
-#define NR_SOFTIRQS                       7
+#define TRACE_SOFTIRQ                     7
+#define NR_SOFTIRQS                       8
 
 #ifndef __ASSEMBLY__